import axios from "axios";
import {env} from "../../../env.js";

const api = axios.create({
    baseURL:env.base_url,
    timeout: 5000,
    responseType:'json',
    withCredentials:'',
    headers:{
    }
})
// axios.interceptors.request.use(
// )
let result = {
    code:200,
    message:"",
    success:true,
    timestamp:"",
    data:""
}
// 响应拦截器
const responseInterceptor = api.interceptors.response.use(
    function (response) {
        // closeLoading();
        result = response.data
        console.log("result",result)
        if (result.code===200){
            console.log("成功");
            // ElMessage({
            //     message: data.message,
            //     type: 'success',
            // })
        }else{
            console.log("失败");
            // ElNotification({
            //     title: 'Error',
            //     message: data.message,
            //     type: 'error',
            // })

        }
        return result.data
    },function (error) {
        return Promise.reject(error)
    }
)
export default api;